/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PlainStyleDlg.java
 *
 * Created on 2011-11-7, 18:40:38
 */
package qrcodetool;

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JColorChooser;
import javax.swing.JFrame;

/**
 *
 * @author zhanqxun
 */
public class PlainStyleDlg extends javax.swing.JDialog {

    private Color color;
    private Color iColor;
    private Color oColor;
    private Color editColor;

    /** Creates new form PlainStyleDlg */
    public PlainStyleDlg(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        if (color != null) {
            g.setColor(color);
            g.fill3DRect(0, 400, 100, 100, true);
        }
        if (iColor != null) {
            g.setColor(iColor);
            g.fill3DRect(150, 400, 100, 100, true);
        }
        if (oColor != null) {
            g.setColor(oColor);
            g.fill3DRect(300, 400, 100, 100, true);
        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        m_ChangeColorBtn = new javax.swing.JButton();
        m_ColorLabel = new javax.swing.JLabel();
        m_ColorLabel1 = new javax.swing.JLabel();
        m_ChangeColorBtn1 = new javax.swing.JButton();
        m_ColorLabel2 = new javax.swing.JLabel();
        m_ChangeColorBtn2 = new javax.swing.JButton();
        m_EditColorBtn = new javax.swing.JButton();
        m_ColorLabel3 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(qrcodetool.QRCodeToolApp.class).getContext().getResourceMap(PlainStyleDlg.class);
        m_ChangeColorBtn.setText(resourceMap.getString("m_ChangeColorBtn.text")); // NOI18N
        m_ChangeColorBtn.setName("m_ChangeColorBtn"); // NOI18N
        m_ChangeColorBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_ChangeColorBtnActionPerformed(evt);
            }
        });

        m_ColorLabel.setText(resourceMap.getString("m_ColorLabel.text")); // NOI18N
        m_ColorLabel.setName("m_ColorLabel"); // NOI18N

        m_ColorLabel1.setName("m_ColorLabel1"); // NOI18N

        m_ChangeColorBtn1.setText(resourceMap.getString("m_ChangeColorBtn1.text")); // NOI18N
        m_ChangeColorBtn1.setName("m_ChangeColorBtn1"); // NOI18N
        m_ChangeColorBtn1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_ChangeColorBtn1ActionPerformed(evt);
            }
        });

        m_ColorLabel2.setName("m_ColorLabel2"); // NOI18N

        m_ChangeColorBtn2.setText(resourceMap.getString("m_ChangeColorBtn2.text")); // NOI18N
        m_ChangeColorBtn2.setName("m_ChangeColorBtn2"); // NOI18N
        m_ChangeColorBtn2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_ChangeColorBtn2ActionPerformed(evt);
            }
        });

        m_EditColorBtn.setText(resourceMap.getString("m_EditColorBtn.text")); // NOI18N
        m_EditColorBtn.setName("m_EditColorBtn"); // NOI18N
        m_EditColorBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_EditColorBtnActionPerformed(evt);
            }
        });

        m_ColorLabel3.setName("m_ColorLabel3"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(m_ChangeColorBtn)
                                    .addComponent(m_ChangeColorBtn1))
                                .addGap(29, 29, 29)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(m_ColorLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(m_ColorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(m_ChangeColorBtn2)
                                .addGap(29, 29, 29)
                                .addComponent(m_ColorLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(m_EditColorBtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 48, Short.MAX_VALUE)
                        .addComponent(m_ColorLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(27, 27, 27))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(m_ChangeColorBtn)
                    .addComponent(m_ColorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(m_ChangeColorBtn1)
                    .addComponent(m_ColorLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(m_ColorLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(m_ChangeColorBtn2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 121, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(m_EditColorBtn)
                    .addComponent(m_ColorLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void m_ChangeColorBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_ChangeColorBtnActionPerformed
// TODO add your handling code here:
    color = JColorChooser.showDialog(this,
            "Color", Color.black);
    if (color != null) {
        m_ColorLabel.setText(color.toString());
        this.repaint();
    }

}//GEN-LAST:event_m_ChangeColorBtnActionPerformed

private void m_ChangeColorBtn1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_ChangeColorBtn1ActionPerformed
// TODO add your handling code here:
    iColor = JColorChooser.showDialog(this,
            "Color", Color.black);
    if (iColor != null) {
        m_ColorLabel1.setText(iColor.toString());
        this.repaint();
    }
}//GEN-LAST:event_m_ChangeColorBtn1ActionPerformed

private void m_ChangeColorBtn2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_ChangeColorBtn2ActionPerformed
// TODO add your handling code here:
    oColor = JColorChooser.showDialog(this,
            "Color", Color.black);
    if (oColor != null) {
        m_ColorLabel2.setText(oColor.toString());
        this.repaint();
    }
}//GEN-LAST:event_m_ChangeColorBtn2ActionPerformed

    private void m_EditColorBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_EditColorBtnActionPerformed
        // TODO add your handling code here:
        editColor = JColorChooser.showDialog(this,
                "Color", Color.black);
        if (editColor != null) {
            m_ColorLabel3.setText(editColor.toString());
            this.repaint();
        }
    }//GEN-LAST:event_m_EditColorBtnActionPerformed
    public Color getColor() {
        if (color != null) {
            return color;
        }
        return Color.black;
    }

    public Color getIColor() {
        if (iColor != null) {
            return iColor;
        }
        return Color.black;
    }

    public Color getOColor() {
        if (oColor != null) {
            return oColor;
        }
        return Color.black;
    }
    
     public Color getEditColor() {
        if (editColor != null) {
            return editColor;
        }
        return Color.black;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(PlainStyleDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(PlainStyleDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(PlainStyleDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(PlainStyleDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                PlainStyleDlg dialog = new PlainStyleDlg(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton m_ChangeColorBtn;
    private javax.swing.JButton m_ChangeColorBtn1;
    private javax.swing.JButton m_ChangeColorBtn2;
    private javax.swing.JLabel m_ColorLabel;
    private javax.swing.JLabel m_ColorLabel1;
    private javax.swing.JLabel m_ColorLabel2;
    private javax.swing.JLabel m_ColorLabel3;
    private javax.swing.JButton m_EditColorBtn;
    // End of variables declaration//GEN-END:variables
}
